const {
	request,
} = require('@utils/apis')

module.exports = {

	loginAction(cxt, params) {
		let reqPro = request('API_LOGIN', params)
		return reqPro.then(result => {
			if (result.responseHeader.status == '00') {
				cxt.commit('LOG_IN', result.response.docs[0]);
				return Promise.resolve()
			} else {
				return Promise.reject(result.responseHeader.errorinfo)
			}
		})
	},

	logoutAction(cxt) {
		let reqPro = request('API_LOGOUT')
		return reqPro.then(result => {
			if (result.responseHeader.status == '00') {
				cxt.commit('LOG_OUT')
				return Promise.resolve()
			} else {
				return Promise.reject(result.responseHeader.errorinfo)
			}
		})
	},
}